package com.heima.wemedia.controller;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmChannelPageDto;
import com.heima.model.wemedia.pojos.WmChannel;
import com.heima.wemedia.service.WmChannelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author jack
 * @data 2024 9:12
 */
@RestController
@RequestMapping("/api/v1/channel")
public class WmChannelController {
    @Autowired
    private WmChannelService wmChannelService;

    /**
     * 查询所有可用频道
     *
     * @return
     */
    @GetMapping("/channels")
    public ResponseResult channels(){
        return wmChannelService.findAll();
    }

    @PostMapping("/save")
    public ResponseResult saveChannel(@RequestBody WmChannel wmChannel){
        return wmChannelService.saveChannel(wmChannel);
    }

    @PostMapping("/list")
    public ResponseResult searchName(@RequestBody WmChannelPageDto dto){
        return wmChannelService.searchName(dto);
    }
    @GetMapping("/del/{id}")
    public ResponseResult deleteChannel(@PathVariable Integer id){
        return wmChannelService.deleteChannel(id);
    }
    @PostMapping("/update")
    public ResponseResult updateChannel(@RequestBody WmChannel wmChannel){
        return wmChannelService.updateChannel(wmChannel);
    }
}
